﻿#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<graphics.h>
#include<windows.h>
#include<stdlib.h>
#include<time.h>

void test1()
{
	setlinecolor(RGB(192, 192, 192));
	setlinestyle(PS_SOLID, 2);
	for (int i = 0; i < 800; i += 20)
	{
		line(i, 0, i, 499);
	}
	for (int i = 0; i < 500; i += 20)
	{
		line(0, i, 799, i);
	}
}
void test2()
{
	//填充颜色
	//setfillcolor(RGB(128,255,255));
	//无填充
	//rectangle(0, 0, 799, 499);
	//有边框填充
	//fillrectangle(10, 10, 30, 30);
	//无边框填充
	//solidrectangle(10, 10, 30, 30);
	setfillcolor(RGB(233, 133, 83));
	for (int i = 0; i < 800; i += 20)
	{
		fillrectangle(i, 0, i+20, 0+20);	
		fillrectangle(i, 480, i + 20, 480 + 20);
	}
	for (int i = 20; i < 500; i += 20)
	{	
		fillrectangle(0, i, 0+20, i+20);
		fillrectangle(780, i, 780 + 20, i + 20);
	}
}
void test3()
{
	settextcolor(BLACK);
	settextstyle(20,0,L"宋体");
	outtextxy(0, 0, L"●");
	//获取文字宽度，高度
	int ret = textwidth(L"哈哈");
	int cout = textheight(L"哈哈");
}
int main()
{
	//创建一个窗口
	initgraph(800,500,EW_SHOWCONSOLE);
	//获取窗口的宽度、高度
	int width = getwidth();
	int height = getheight();
	//设置背景颜色
	setbkcolor(RGB(233,133,83));
	//设置背景模式
	setbkmode(TRANSPARENT);
	//清空窗口
	cleardevice();
	//图形绘制
	putpixel(0,0,RED);
	test1();
	test2();
	test3();
	//消息处理
	//信息消息判断
	MouseHit();
	//获取鼠标信息
	MOUSEMSG msg = GetMouseMsg();
	//WM_LBUTTONDOWN 鼠标左击消息
	//WM_RBUTTONDOWN 鼠标右击消息
	//窗口信息
	HWND wnd = GetHWnd(); //获取窗口句柄
	SetWindowText(wnd, L"贪吃蛇");   //修改窗口标题 
	int ret = MessageBoxW(wnd, L"我用什么才能留住你", L"庄梦涵", MB_ICONQUESTION | MB_OKCANCEL);
	if (ret == IDOK)//返回值检测
		printf("%d", ret);
	//6.防止闪屏幕
	
	//关闭窗口
	system("pause");
	closegraph();
	system("pause");
	return 0;
}